﻿using System;
using System.Linq.Expressions;
using ApiManage.Core.Repository.MongoDB;
using ApiManage.Models.MongoMappings.Project;
using Autofac.Extras.DynamicProxy;
using MongoDB.Driver;
using Rhonin.Common.Components;
using Rhonin.Common.UnitOfWork.Transaction;

namespace ApiManage.Applications.Mongo.Project.Impl
{
    [Component]
    [Intercept(typeof(TransactionInterceptor))]
    public class InterfaceInfoService : IInterfaceInfoService
    {
        private readonly IProjectRepository<InterfaceInfo> _interfaceRepository;
        public InterfaceInfoService(IProjectRepository<InterfaceInfo> interfaceRepository)
        {
            _interfaceRepository = interfaceRepository;
        }


        public void Insert(InterfaceInfo param)
        {
            _interfaceRepository.InsertOne(param);
        }

        public void Update(Expression<Func<InterfaceInfo, bool>> fitter, UpdateDefinition<InterfaceInfo> updateDefinition)
        {
            _interfaceRepository.Update(fitter, updateDefinition);
        }
        public void Delete(Expression<Func<InterfaceInfo, bool>> fitter)
        {
            _interfaceRepository.Delete(fitter);
        }
    }
}
